package com.project.service;

import com.project.common.utils.MyPageHelper;
import com.project.dao.ExamPaperMapper;
import com.project.entity.ExamPaper;
import com.project.service.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional(rollbackFor = Exception.class)
@Service
public class ExamPaperServiceImpl extends BaseService implements ExamPaperService {

    @Autowired
    ExamPaperMapper examPaperMapper;


    @Override
    public int add(ExamPaper exampaper){
        return examPaperMapper.insertSelective(exampaper);
    }

    @Override
    public ExamPaper findById(Integer id){
        return examPaperMapper.selectByPrimaryKey(id);
    }

    @Override
    public void remove(Integer id){
        examPaperMapper.deleteByPrimaryKey(id);
    }
    @Override
    public List<ExamPaper> findByCondition(ExamPaper exampaper){
        MyPageHelper.setPageParam(exampaper);
        return examPaperMapper.selectBatchByCondition(exampaper);
    }
    @Override
    public List<ExamPaper> findByTeacherid(Integer teacherid){
        return examPaperMapper.selectByteacherid(teacherid);
    }
    @Override
    public List<ExamPaper> findByCourseid(Integer teacherid,Integer courseid){
        return examPaperMapper.selectBycourseid(teacherid,courseid);
    }
    @Override
    public int modify(ExamPaper examPaper){
        return examPaperMapper.updateByPrimaryKeySelective(examPaper);
    }
}
